package org.aiesec.fortaleza.xmatch.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;

import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;

@Entity
@SequenceGenerator(name = EntityBase.SEQUENCE_NAME, sequenceName = "SEQUENCE_MEMBRO")
@NamedQueries(value = {
		@NamedQuery(name = "Membro.queryPesquisa", query = "select new Membro(m.id, m.nome, m.email, m.posicao) from Membro m"),
		@NamedQuery(name = "Membro.validaDuplicata", query = "select count(*) as total from Membro m where m.nome=:nome or m.email=:email")})
public class Membro extends EntityBase {
	@Column(length = 70, nullable = false, unique = true)
	@NotEmpty(message = "#{messages['membro.nome.requerido']}")
	@NotNull(message = "membro.nome.requerido")
	@Length(max = 70, message = "nome.tamanho.invalido")
	private String nome;
	@Column(length = 70, unique = true, nullable = false)
	@Email(message = "#{messages['email.invalido']}")
	@Length(max = 70, message = "email.tamanho.invalido")
	private String email;
	@Column(length = 20)
	@Length(max = 20, message = "posicao.tamanho.invalido")
	private String posicao;

	public Membro(Long id, String nome, String email, String posicao) {
		super();
		this.id = id;
		this.nome = nome;
		this.email = email;
		this.posicao = posicao;
	}

	public Membro(Long id, String nome) {
		super();
		this.id = id;
		this.nome = nome;
	}

	public Membro() {
		// TODO Auto-generated constructor stub
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getNome() {
		return nome;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public void setPosicao(String posicao) {
		this.posicao = posicao;
	}

	public String getPosicao() {
		return posicao;
	}

}
